<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/layer/css/layui.css}" rel="stylesheet">
    <link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}" ></script>
    <script th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/layer/layui.js}"></script>
    <style>
        .layui-form-label {
            width: 100px;
        }

    </style>
</head>
<body>
<form class="layui-form" id="userFrm" >
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">卡号</label>
            <div class="layui-input-inline">
                <input type="text" name="membernumber" id="membernumber"
                       autocomplete="off" class="layui-input" th:value="${mm.getMembernumber()}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">会员类型</label>
            <div class="layui-input-inline">
                <select  class="form-control" id="memberGradeid" name="memberGradeid">
                    <option th:selected="${lii.getMemberGradeid() == mm.getMemberGradeid()}"
                            th:each="lii:${li}" th:value="${lii.getMemberGradeid()}" th:text="${lii.getMembergrade()}"></option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="clientname" id="clientname" placeholder="用户姓名" autocomplete="off" class="layui-input" th:value="${mm.getClientname()}">
                <input class="hidden" id="clientid" name="clientid" th:value="${mm.getClientid()}">
                <input class="hidden" id="memberid" name="memberid" th:value="${mm.getMemberid()}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block" >
                <input type="text" name="phoneNumber" id="phoneNumber" th:value="${mm.getPhoneNumber()}" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">证件号码</label>
            <div class="layui-input-inline">
                <input type="text" name="identity" id="identity" th:value="${mm.getIdentity()}" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">证件类型</label>
            <div class="layui-input-inline">
                <input type="text" name="idType" id="idType" th:value="${mm.getIdType()}" placeholder="" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

    </div>
    <div class="layui-inline">
        <label class="layui-form-label">会员生日</label>
        <div class="layui-input-inline">
            <input type="date" name="birthday" id="birthday" th:value="${#dates.format(mm.getBirthday(),'yyyy-MM-dd')}" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">单位</label>
        <div class="layui-input-inline">
            <input type="text" name="unit" id="unit" th:value="${mm.getUnit()}" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input type="text" id="adress" name="adress" th:value="${mm.getAdress()}" placeholder="地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <button class="layui-btn" lay-submit="" lay-filter="updateUser">提交</button>
        <button class="layui-btn layui-btn-warm" type="reset">重置</button>
    </div>
</form>
<script type="text/javascript">
    var form;
    var layer;
    layui.use(['form', 'layer', 'jquery', 'laydate'], function () {
        form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        //如果父页面有layer就是用父页面的，没有就导入
        layer = parent.layer === undefined ? layui.layer : parent.layer;

        //绑定时间选择器
        laydate.render({
            elem: '#hiredate'
        });

        //监听提交，使用layui form submit事件
        form.on('submit(updateUser)', function () {
            //form获取数据
            var data = $('#userFrm').serialize();
            $.post(
                '/member/savaupdate',
                data,
                function (data) {
                    console.log(data);
                    if (data.code == 0) {
                        //弹出成功的提示
                        layer.msg(data.msg, {icon: 1, time: 2000});
                        //重载表格
                        parent.tableIns.reload();
                        //关闭窗口
                        var index = layer.getFrameIndex(window.name);
                        layer.close(index);
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 3000});
                    }
                }
            );
            return false;
        });

        /**
         * 监听用户姓名失去焦点事件，请求后台自动生成对应的全拼拼音
         */

    });

</script>
</body>
</html>